/**
 * Copyright 2013 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.QuestionsStatus;

/**
 *  TABLE CAU HOI
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 17:52:37
 */
@Entity
@Table(name = "QUESTIONS")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "QUESTIONS_SEQ", allocationSize = 1)
public class Questions implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -695424618055804872L;
	
	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="QUESTIONS_ID_PK")
	private Integer id;
	
	/**
	 * CAU HOI
	 */
	@Basic
	@Column(name = "USER_PHONE", length = 20)
	private String userPhone;
	
	/**
	 * CAU HOI KHONG DAU
	 */
	@Basic
	@Column(name = "USER_NAME", length = 100)
	private String userName;
	
	/**
	 * MO TA CAU HOI
	 */
	@Basic
	@Column(name = "USER_EMAIL", length = 100)
	private String userEmail;
	
	/**
	 * CAU HOI
	 */
	@Basic
	@Column(name = "CONTENT", length = 500)
	private String content;
	
	/**
	 * CAU HOI KHONG DAU
	 */
	@Basic
	@Column(name = "CONTENT_TEXT", length = 500)
	private String contentText;
	
	/**
	 * MO TA CAU HOI
	 */
	@Basic
	@Column(name = "ANSWER", length = 4000)
	private String answer;
	
	/**
	 * MO TA CAU HOI
	 */
	@Basic
	@Column(name = "ANSWER_TEXT", length = 4000)
	private String answerText;
	
	/**
	 * USER TAO
	 */
	@ManyToOne(targetEntity = Users.class)
	@JoinColumn(name = "USER_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTIONS_USER_FK")
	private Users users;
	
	/**
	 * NGUOI TAO
	 */
	@ManyToOne(targetEntity = CmsUser.class)
	@JoinColumn(name = "CMS_USER_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTIONS_CMS_USER_FK")
	private CmsUser cmsUser;
	
	/**
	 * LOAI CAU HOI
	 */
	@ManyToOne(targetEntity = GroupCategory.class)
	@JoinColumn(name = "GROUP_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTIONS_GROUP_CATEGORY_FK")
	private GroupCategory groupCategory;
	
	/**
	 * LOAI CAU HOI
	 */
	@ManyToOne(targetEntity = TechniqueCategory.class)
	@JoinColumn(name = "TECHNIQUE_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTION_TECHNIQUE_CATEGORY_FK")
	private TechniqueCategory techniqueCategory;
	
	/**
	 * BAI VIET TRA LOI
	 */
	@ManyToOne(targetEntity = Article.class)
	@JoinColumn(name = "ARTICLE_ANSWER_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTIONS_ARTICLE_ANSWER_FK")
	private Article articleAnswer;
	
	/**
	 * BAI VIET TRA LOI
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "QUESTIONS_MEDIA_FK")
	private Media media;
	
	/**
	 * TRANG THAI CAU HOI
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.QuestionsStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="QUESTIONS_STATUSX")
	private QuestionsStatus status;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	/**
	 * THOI GIAN CAP NHAT
	 */
	@Basic
	@Column(name = "UPDATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date updatedTime;
	
	public Integer getId() {
		return id;
	}

	public Users getUsers() {
		return users;
	}

	public void setUsers(Users users) {
		this.users = users;
	}

	public GroupCategory getGroupCategory() {
		return groupCategory;
	}

	public void setGroupCategory(GroupCategory groupCategory) {
		this.groupCategory = groupCategory;
	}

	public QuestionsStatus getStatus() {
		return status;
	}

	public void setStatus(QuestionsStatus status) {
		this.status = status;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public CmsUser getCmsUser() {
		return cmsUser;
	}

	public void setCmsUser(CmsUser cmsUser) {
		this.cmsUser = cmsUser;
	}

	public String getAnswer() {
		return answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getContentText() {
		return contentText;
	}

	public void setContentText(String contentText) {
		this.contentText = contentText;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAnswerText() {
		return answerText;
	}

	public void setAnswerText(String answerText) {
		this.answerText = answerText;
	}

	public String getUserPhone() {
		return userPhone;
	}

	public void setUserPhone(String userPhone) {
		this.userPhone = userPhone;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserEmail() {
		return userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public TechniqueCategory getTechniqueCategory() {
		return techniqueCategory;
	}

	public void setTechniqueCategory(TechniqueCategory techniqueCategory) {
		this.techniqueCategory = techniqueCategory;
	}

	public Article getArticleAnswer() {
		return articleAnswer;
	}

	public void setArticleAnswer(Article articleAnswer) {
		this.articleAnswer = articleAnswer;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public Date getUpdatedTime() {
		return updatedTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}
	
	
}
